-- 战绩榜
local GuildWarGuildScorePop = class("GuildWarGuildScorePop", app.mvc.ViewBase)
local GuildWarGuildScoreCell = import("..renders.GuildWarGuildScoreCell")
local ListViewVertical = require("app.widget.listview.ListViewVertical")


local CSGuildWarGuildInfo = require("app.public.dao.CSGuildWarGuildInfo")


GuildWarGuildScorePop.VIEW_ROOT_RES = Res.CSGuildWarGuildScore

function GuildWarGuildScorePop:init()
    self.super.init(self)
    display.setCascadeOpacityEnabled(self._root, true)
    self._ui.Button_close:addClickEventListener(function()
        self:closeView()
    end)
    -- self:registerViewEvent({
    --     {name = ViewEvent.CSGuildWar_GuildRankInfo, callback = handler(self, self._onGetGuildRankInfo)},
       
    -- })
    local params = {
        renderClass = GuildWarGuildScoreCell,   
    }
    self._listview = ListViewVertical.new(self._ui["Panel/ScrollView"], params)


    UD.csGuildWarData:C2S_WorldGuildWarRank()
    self:refresh()
end


-- function GuildWarGuildScorePop:_onGetGuildRankInfo(eventName, datas)
--     self._data = datas
--     self:refresh()
-- end


function GuildWarGuildScorePop:setData(data)
    -- local ds = self:testData()
    self._data = data
    self:refresh()
end
function GuildWarGuildScorePop:refresh()
    -- local ds = self:testData()
    self._listview:reloadData(self._data or {})
end


-- function GuildWarGuildScorePop:testData()
--     local d = {
--         info = {
--             memberNum = 1,
--             name = "1111",
--             server = 1,
--         },
--         winTimes = 1,
--         loseTimes = 2,
--         score = 0
--     }
--     local members = {}
--     for i =1, 100 do
--         table.insert(members, d)
--     end

--     local datas = {}
--     for k, v in pairs(members) do
--         local m = CSGuildWarGuildInfo.new()
--         m:read(v)
--         table.insert( datas, m )
--     end
--     return datas
-- end

return GuildWarGuildScorePop